/**
 @file ctc_usw_chip_cli.c

 @date 2023-07-08

 @version v2.0

---file comments----
*/

/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/
#include "sal.h"
#include "ctc_cli.h"
#include "ctc_cli_common.h"
#include "ctc_api.h"
#include "ctcs_api.h"
#include "ctc_diag.h"
#include "ctc_error.h"
#include "ctc_debug.h"
#include "ctc_diag_cli.h"
#include "ctc_usw_diag_cli.h"

extern int32
sys_usw_diag_get_drop_reason(uint8 lchip, uint16 drop_reason);

CTC_CLI(ctc_cli_usw_diag_drop_reason,
        ctc_cli_usw_diag_drop_reason_cmd,
        "show diag (drop-reason REASON)",
        CTC_CLI_SHOW_STR,
        CTC_CLI_DIAG_M_STR,
        "Drop Reason",
        "Drop Reason Value"
        )
{
    uint32 index = 0;
    uint32 reason = 0;
    int32 ret = 0;
    
    index = CTC_CLI_GET_ARGC_INDEX("drop-reason");
    if (index != 0xFF)
    {
        CTC_CLI_GET_UINT8("reason id", reason, argv[index + 1]);
        ret = sys_usw_diag_get_drop_reason(g_api_lchip, reason);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% ret = %d, %s \n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return ret;
}

int32
ctc_usw_diag_cli_init(void)
{
    install_element(CTC_SDK_MODE, &ctc_cli_usw_diag_drop_reason_cmd);
    return CLI_SUCCESS;
}

int32
ctc_usw_diag_cli_deinit(void)
{
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_diag_drop_reason_cmd);
    return CLI_SUCCESS;
}